//
//  BookViewItem.m
//  CMS
//
//  Created by Vuong Van Khanh on 11/13/12.
//  Copyright (c) 2012 Rikkei. All rights reserved.
//

#import "BookViewItem.h"

@implementation BookViewItem

@synthesize reuseIdentifier;
@synthesize index = _index;
@synthesize checkedImageView = _checkedImageView;
@synthesize updatingImageView = _updatingImageView;
@synthesize selected = _selected;
@synthesize lblContentId = _lblContentId;
@synthesize lblTitle = _lblTitle;
@synthesize updateButton = _updateButton;
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code

//        _checkedImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BookViewChecked.png"]];
//        _updatingImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"update.jpeg"]];
//        [_checkedImageView setHidden:NO];
//        [_updatingImageView setHidden:NO];
        
//        [self addSubview:_checkedImageView];
//        [self addSubview:_updatingImageView];
//        [self addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
//    NSLog(@"call to init BookViewItem");
}

- (void)awakeFromNib{
    [_checkedImageView setHidden:YES];
    [_updatingImageView setHidden:YES];
    [self setBackgroundColor:[UIColor clearColor]];
    [self addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)setSelected:(BOOL)selected {
    _selected = selected;
    if (_selected) {
        [_checkedImageView setHidden:NO];
    }
    else {
        [_checkedImageView setHidden:YES];
    }
}

- (void)buttonClicked:(id)sender {
    [self setSelected:_selected ? NO : YES];
}


- (IBAction)updateButtonClicked:(id)sender {
    NSLog(@"updateButtonClicked");
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
